<!DOCTYPE HTML>
<html lang="en" >
    
    <head>
        
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <title>自定义组件 | 微信小程序</title>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="">
        <meta name="generator" content="GitBook 2.6.7">
        
        
        <meta name="HandheldFriendly" content="true"/>
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
        <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
        
    <link rel="stylesheet" href="../gitbook/style.css">
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-highlight/website.css">
        
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-search/search.css">
        
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-fontsettings/website.css">
        
    
    

        
    
    
    <link rel="next" href="../di-yi-jie-ff1a-wang-luo-qing-qiu-api.html" />
    
    
    <link rel="prev" href="../di-san-zhang-ff1a-chang-yong-zu-jian/di-liu-jie-ff1a-input-zu-jian.html" />
    

        
    </head>
    <body>
        
        
    <div class="book"
        data-level="3.7"
        data-chapter-title="自定义组件"
        data-filepath="di-san-zhang-ff1a-chang-yong-zu-jian/zi-ding-yi-zu-jian.md"
        data-basepath=".."
        data-revision="Tue Feb 12 2019 17:48:38 GMT+0800 (中国标准时间)"
        data-innerlanguage="">
    

<div class="book-summary">
    <nav role="navigation">
        <ul class="summary">
            
            
            
            

            

            
    
        <li class="chapter " data-level="0" data-path="index.html">
            
                
                    <a href="../index.html">
                
                        <i class="fa fa-check"></i>
                        
                        Introduction
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1" data-path="chapter1.html">
            
                
                    <a href="../chapter1.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.</b>
                        
                        第一章：小程序前奏
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1" data-path="chapter1/di-yi-jie-ff1a-ren-shi-xiao-cheng-xu.html">
            
                
                    <a href="../chapter1/di-yi-jie-ff1a-ren-shi-xiao-cheng-xu.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.1.</b>
                        
                        第一节：认识小程序
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="chapter1/di-er-jie-ff1a-zhun-bei-gong-zuo.html">
            
                
                    <a href="../chapter1/di-er-jie-ff1a-zhun-bei-gong-zuo.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.2.</b>
                        
                        第二节：准备工作
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="chapter1/di-san-jie-ff1a-kai-fa-gong-ju-jie-shao.html">
            
                
                    <a href="../chapter1/di-san-jie-ff1a-kai-fa-gong-ju-jie-shao.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.3.</b>
                        
                        第三节：开发工具介绍
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="chapter1/di-liu-jie-ff1a-wxss-yu-fa.html">
            
                
                    <a href="../chapter1/di-liu-jie-ff1a-wxss-yu-fa.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.4.</b>
                        
                        第六节：WXSS语法
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2" data-path="di-er-zhang-ff1a-kai-fa-zhun-bei-gong-zuo.html">
            
                
                    <a href="../di-er-zhang-ff1a-kai-fa-zhun-bei-gong-zuo.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.</b>
                        
                        第二章：小程序基础
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1" data-path="di-er-zhang-ff1a-kai-fa-zhun-bei-gong-zuo/di-yi-jie-ff1a-kuang-jia-jie-shao.html">
            
                
                    <a href="../di-er-zhang-ff1a-kai-fa-zhun-bei-gong-zuo/di-yi-jie-ff1a-kuang-jia-jie-shao.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.</b>
                        
                        第一节：项目结构
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="di-er-zhang-ff1a-kai-fa-zhun-bei-gong-zuo/di-er-jie-ff1a-wxml-yu-fa.html">
            
                
                    <a href="../di-er-zhang-ff1a-kai-fa-zhun-bei-gong-zuo/di-er-jie-ff1a-wxml-yu-fa.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.2.</b>
                        
                        第二节：配置
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.3" data-path="di-er-zhang-ff1a-kai-fa-zhun-bei-gong-zuo/di-san-jie-ff1a-wxml-yu-fa.html">
            
                
                    <a href="../di-er-zhang-ff1a-kai-fa-zhun-bei-gong-zuo/di-san-jie-ff1a-wxml-yu-fa.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.3.</b>
                        
                        第三节：WXML语法
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.4" data-path="di-er-zhang-ff1a-kai-fa-zhun-bei-gong-zuo/di-si-jie-ff1a-wxss-yu-fa.html">
            
                
                    <a href="../di-er-zhang-ff1a-kai-fa-zhun-bei-gong-zuo/di-si-jie-ff1a-wxss-yu-fa.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.4.</b>
                        
                        第五节：事件
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.5" data-path="di-er-zhang-ff1a-kai-fa-zhun-bei-gong-zuo/di-liu-jie-ff1a-wxss-yu-fa.html">
            
                
                    <a href="../di-er-zhang-ff1a-kai-fa-zhun-bei-gong-zuo/di-liu-jie-ff1a-wxss-yu-fa.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.5.</b>
                        
                        第六节：WXSS语法
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.6" data-path="di-er-zhang-ff1a-kai-fa-zhun-bei-gong-zuo/di-qi-jie-ff1a-flex-bu-ju.html">
            
                
                    <a href="../di-er-zhang-ff1a-kai-fa-zhun-bei-gong-zuo/di-qi-jie-ff1a-flex-bu-ju.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.6.</b>
                        
                        第七节：flex布局
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.7" data-path="di-er-zhang-ff1a-kai-fa-zhun-bei-gong-zuo/di-bajie-ff1a-app-sheng-ming-zhou-qi.html">
            
                
                    <a href="../di-er-zhang-ff1a-kai-fa-zhun-bei-gong-zuo/di-bajie-ff1a-app-sheng-ming-zhou-qi.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.7.</b>
                        
                        第八节：APP对象
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.8" data-path="di-er-zhang-ff1a-kai-fa-zhun-bei-gong-zuo/di-jiu-jie-ff1a-page-dui-xiang.html">
            
                
                    <a href="../di-er-zhang-ff1a-kai-fa-zhun-bei-gong-zuo/di-jiu-jie-ff1a-page-dui-xiang.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.8.</b>
                        
                        第九节：Page对象
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.9" data-path="di-er-zhang-ff1a-kai-fa-zhun-bei-gong-zuo/di-shi-zhang-ff1a-wxs-yu-fa.html">
            
                
                    <a href="../di-er-zhang-ff1a-kai-fa-zhun-bei-gong-zuo/di-shi-zhang-ff1a-wxs-yu-fa.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.9.</b>
                        
                        第十节：WXS语法
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3" data-path="di-san-zhang-ff1a-chang-yong-zu-jian.html">
            
                
                    <a href="../di-san-zhang-ff1a-chang-yong-zu-jian.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.</b>
                        
                        第三章：常用组件
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.1" data-path="di-san-zhang-ff1a-chang-yong-zu-jian/di-yi-jie-ff1a-shi-tu-rong-qi-zu-jian.html">
            
                
                    <a href="../di-san-zhang-ff1a-chang-yong-zu-jian/di-yi-jie-ff1a-shi-tu-rong-qi-zu-jian.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.1.</b>
                        
                        第一节：scroll-view组件
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="di-san-zhang-ff1a-chang-yong-zu-jian/di-er-jieff1a-swiper-zu-jian.html">
            
                
                    <a href="../di-san-zhang-ff1a-chang-yong-zu-jian/di-er-jieff1a-swiper-zu-jian.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.2.</b>
                        
                        第二节：swiper组件
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="di-san-zhang-ff1a-chang-yong-zu-jian/di-san-jie-ff1a-movable-view-zu-jian.html">
            
                
                    <a href="../di-san-zhang-ff1a-chang-yong-zu-jian/di-san-jie-ff1a-movable-view-zu-jian.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.3.</b>
                        
                        第三节：movable-view组件
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.4" data-path="di-san-zhang-ff1a-chang-yong-zu-jian/di-sijie-ff1a-icon-zu-jian.html">
            
                
                    <a href="../di-san-zhang-ff1a-chang-yong-zu-jian/di-sijie-ff1a-icon-zu-jian.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.4.</b>
                        
                        第四节：icon组件
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.5" data-path="di-san-zhang-ff1a-chang-yong-zu-jian/di-wu-jie-ff1a-text-zu-jian.html">
            
                
                    <a href="../di-san-zhang-ff1a-chang-yong-zu-jian/di-wu-jie-ff1a-text-zu-jian.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.5.</b>
                        
                        第五节：text组件
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.6" data-path="di-san-zhang-ff1a-chang-yong-zu-jian/di-liu-jie-ff1a-input-zu-jian.html">
            
                
                    <a href="../di-san-zhang-ff1a-chang-yong-zu-jian/di-liu-jie-ff1a-input-zu-jian.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.6.</b>
                        
                        第六节：input组件
                    </a>
            
            
        </li>
    
        <li class="chapter active" data-level="3.7" data-path="di-san-zhang-ff1a-chang-yong-zu-jian/zi-ding-yi-zu-jian.html">
            
                
                    <a href="../di-san-zhang-ff1a-chang-yong-zu-jian/zi-ding-yi-zu-jian.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.7.</b>
                        
                        自定义组件
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4" >
            
            <span><b>4.</b> 第四章：小程序API</span>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.1" data-path="di-yi-jie-ff1a-wang-luo-qing-qiu-api.html">
            
                
                    <a href="../di-yi-jie-ff1a-wang-luo-qing-qiu-api.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.1.</b>
                        
                        第一节：网络请求API
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="5" data-path="di-liu-zhang-ff1a-es6-yu-fa.html">
            
                
                    <a href="../di-liu-zhang-ff1a-es6-yu-fa.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.</b>
                        
                        第五章：ES6语法
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="5.1" data-path="di-liu-zhang-ff1a-es6-yu-fa/di-yi-jie-ff1a-shi-yao-shi-es6-yu-fa.html">
            
                
                    <a href="../di-liu-zhang-ff1a-es6-yu-fa/di-yi-jie-ff1a-shi-yao-shi-es6-yu-fa.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.1.</b>
                        
                        第一节：什么是ES6语法
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.2" data-path="di-liu-zhang-ff1a-es6-yu-fa/di-er-jie-ff1a-es6-yu-fa.html">
            
                
                    <a href="../di-liu-zhang-ff1a-es6-yu-fa/di-er-jie-ff1a-es6-yu-fa.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.2.</b>
                        
                        第二节：定义变量
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.3" data-path="di-liu-zhang-ff1a-es6-yu-fa/di-san-jie-ff1a-han-shu.html">
            
                
                    <a href="../di-liu-zhang-ff1a-es6-yu-fa/di-san-jie-ff1a-han-shu.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.3.</b>
                        
                        第三节：函数
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.4" data-path="di-liu-zhang-ff1a-es6-yu-fa/di-si-jie-ff1a-lei.html">
            
                
                    <a href="../di-liu-zhang-ff1a-es6-yu-fa/di-si-jie-ff1a-lei.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.4.</b>
                        
                        第四节：类
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.5" data-path="di-liu-zhang-ff1a-es6-yu-fa/di-wu-jie-ff1a-mo-kuai.html">
            
                
                    <a href="../di-liu-zhang-ff1a-es6-yu-fa/di-wu-jie-ff1a-mo-kuai.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.5.</b>
                        
                        第五节：模块
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="6" data-path="di-wu-zhang-ff1a-yun-kai-fa.html">
            
                
                    <a href="../di-wu-zhang-ff1a-yun-kai-fa.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.</b>
                        
                        第六章：云开发
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="6.1" data-path="di-yi-jie-ff1a-shi-yao-shi-yun-kai-fa.html">
            
                
                    <a href="../di-yi-jie-ff1a-shi-yao-shi-yun-kai-fa.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.1.</b>
                        
                        第一节：什么是云开发
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.2" data-path="di-er-jie-ff1a-zhu-ce-wei-xin-xiao-cheng-xu.html">
            
                
                    <a href="../di-er-jie-ff1a-zhu-ce-wei-xin-xiao-cheng-xu.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.2.</b>
                        
                        第二节：注册微信小程序
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.3" data-path="di-san-jie-ff1a-kai-tong-yun-kai-fa.html">
            
                
                    <a href="../di-san-jie-ff1a-kai-tong-yun-kai-fa.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.3.</b>
                        
                        第三节：开通云开发
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.4" data-path="di-si-jie-ff1a-shu-ju-ku.html">
            
                
                    <a href="../di-si-jie-ff1a-shu-ju-ku.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.4.</b>
                        
                        第四节：数据库准备
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.5" data-path="di-wu-jie-ff1a-shu-ju-ku-cao-zuo.html">
            
                
                    <a href="../di-wu-jie-ff1a-shu-ju-ku-cao-zuo.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.5.</b>
                        
                        第五节：数据库操作
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.6" data-path="di-liu-jie-ff1a-command-zhi-ling.html">
            
                
                    <a href="../di-liu-jie-ff1a-command-zhi-ling.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.6.</b>
                        
                        第六节：command指令
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.7" data-path="di-qi-jie-ff1a-gao-ji-cha-xun.html">
            
                
                    <a href="../di-qi-jie-ff1a-gao-ji-cha-xun.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.7.</b>
                        
                        第七节：高级查询
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.8" data-path="di-ba-jie-ff1a-wen-jian-shang-chuan.html">
            
                
                    <a href="../di-ba-jie-ff1a-wen-jian-shang-chuan.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.8.</b>
                        
                        第八节：文件操作
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.9" data-path="di-jiu-jie-ff1a-node-huan-jing-da-jian.html">
            
                
                    <a href="../di-jiu-jie-ff1a-node-huan-jing-da-jian.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.9.</b>
                        
                        第九节：node环境搭建
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.10" data-path="di-shi-jie-ff1a-yun-han-shu.html">
            
                
                    <a href="../di-shi-jie-ff1a-yun-han-shu.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.10.</b>
                        
                        第十节：云函数
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.11" data-path="di-shi-yi-jie-ff1a-yun-han-shu-jian-ce-nei-rong-an-quan.html">
            
                
                    <a href="../di-shi-yi-jie-ff1a-yun-han-shu-jian-ce-nei-rong-an-quan.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.11.</b>
                        
                        第十一节：检测内容安全
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.12" data-path="di-shi-er-jie-ff1a-yun-han-shu-tu-pian-jian-huang.html">
            
                
                    <a href="../di-shi-er-jie-ff1a-yun-han-shu-tu-pian-jian-huang.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.12.</b>
                        
                        第十二节：图片鉴黄
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.13" data-path="di-shi-san-jie-ff1a-yong-hu-shou-quan.html">
            
                
                    <a href="../di-shi-san-jie-ff1a-yong-hu-shou-quan.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.13.</b>
                        
                        第十三节：用户授权
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.14" data-path="di-shi-si-jie-ff1a-qi-ta-shou-quan-fang-shi.html">
            
                
                    <a href="../di-shi-si-jie-ff1a-qi-ta-shou-quan-fang-shi.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.14.</b>
                        
                        第十四节：其他授权方式
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    


            
            <li class="divider"></li>
            <li>
                <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
                    Published with GitBook
                </a>
            </li>
            
        </ul>
    </nav>
</div>

    <div class="book-body">
        <div class="body-inner">
            <div class="book-header" role="navigation">
    <!-- Actions Left -->
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../" >微信小程序</a>
    </h1>
</div>

            <div class="page-wrapper" tabindex="-1" role="main">
                <div class="page-inner">
                
                
                    <section class="normal" id="section-">
                    
                        <h1 id="&#x81EA;&#x5B9A;&#x4E49;&#x7EC4;&#x4EF6;&#xFF1A;">&#x81EA;&#x5B9A;&#x4E49;&#x7EC4;&#x4EF6;&#xFF1A;</h1>
<h2 id="&#x4E00;&#x3001;&#x521B;&#x5EFA;&#x7EC4;&#x4EF6;&#xFF1A;">&#x4E00;&#x3001;&#x521B;&#x5EFA;&#x7EC4;&#x4EF6;&#xFF1A;</h2>
<ol>
<li>&#x81EA;&#x5B9A;&#x4E49;&#x4E00;&#x4E2A;<code>components</code>&#x6587;&#x4EF6;&#x5939;&#xFF0C;&#x7528;&#x6765;&#x5B58;&#x653E;&#x6240;&#x6709;&#x81EA;&#x5B9A;&#x4E49;&#x7684;&#x7EC4;&#x4EF6;&#x3002;</li>
<li>&#x518D;&#x9488;&#x5BF9;&#x6BCF;&#x4E00;&#x4E2A;&#x7EC4;&#x4EF6;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x6587;&#x4EF6;&#x5939;&#xFF0C;&#x7528;&#x6765;&#x5B58;&#x653E;&#x8FD9;&#x4E2A;&#x7EC4;&#x4EF6;&#x76F8;&#x5173;&#x7684;&#x6587;&#x4EF6;&#x3002;&#x6BD4;&#x5982;<code>mybox</code>&#x8FD9;&#x4E2A;&#x7EC4;&#x4EF6;&#xFF0C;&#x90A3;&#x4E48;&#x53EF;&#x4EE5;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;<code>mybox</code>&#x7684;&#x4E00;&#x4E2A;&#x6587;&#x4EF6;&#x5939;&#x3002;</li>
<li>&#x5728;&#x6307;&#x5B9A;&#x7EC4;&#x4EF6;&#x7684;&#x6587;&#x4EF6;&#x5939;&#x4E2D;<code>&#x53F3;&#x952E;-&gt;&#x65B0;&#x5EFA;Component</code>&#x521B;&#x5EFA;&#x7EC4;&#x4EF6;&#x3002;&#x8FD9;&#x6837;&#x521B;&#x5EFA;&#x7684;&#x76EE;&#x7684;&#x662F;&#x5728;<code>json</code>&#x6587;&#x4EF6;&#x4E2D;&#x6DFB;&#x52A0;<code>&quot;component&quot;: true</code>&#xFF0C;&#x5C06;&#x5176;&#x7533;&#x660E;&#x4E3A;&#x4E00;&#x4E2A;&#x7EC4;&#x4EF6;&#x3002;</li>
<li>&#x5728;<code>wxml</code>&#x6587;&#x4EF6;&#x4E2D;&#x505A;&#x597D;&#x7EC4;&#x4EF6;&#x7684;&#x8282;&#x70B9;&#x5E03;&#x5C40;&#x3002;&#x6BD4;&#x5982;&#x4EE5;&#x4E0B;&#x4EE3;&#x7801;&#xFF1A;<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-title">view</span> <span class="hljs-attribute">class</span>=<span class="hljs-value">&quot;outter&quot;</span>&gt;</span>
 <span class="hljs-tag">&lt;<span class="hljs-title">view</span> <span class="hljs-attribute">class</span>=<span class="hljs-value">&quot;inner&quot;</span>&gt;</span>&#x77E5;&#x4E86;&#x8BFE;&#x5802;<span class="hljs-tag">&lt;/<span class="hljs-title">view</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-title">view</span>&gt;</span>
</code></pre>
</li>
</ol>
<h2 id="&#x4E8C;&#x3001;&#x4F7F;&#x7528;&#x7EC4;&#x4EF6;&#xFF1A;">&#x4E8C;&#x3001;&#x4F7F;&#x7528;&#x7EC4;&#x4EF6;&#xFF1A;</h2>
<ol>
<li>&#x5728;&#x9700;&#x8981;&#x4F7F;&#x7528;&#x81EA;&#x5B9A;&#x4E49;&#x7EC4;&#x4EF6;&#x7684;&#x9875;&#x9762;&#x7684;<code>json</code>&#x6587;&#x4EF6;&#x4E2D;&#x6CE8;&#x518C;&#x7EC4;&#x4EF6;&#x3002;&#x6DFB;&#x52A0;&#x7C7B;&#x4F3C;&#x5982;&#x4E0B;&#x4EE3;&#x7801;&#xFF1A;<pre><code class="lang-json"> {
   <span class="hljs-string">&quot;usingComponents&quot;</span>: {
     <span class="hljs-string">&quot;mybox&quot;</span>: <span class="hljs-string">&quot;/components/mybox/mybox&quot;</span>
   }
 }
</code></pre>
</li>
<li>&#x7136;&#x540E;&#x5728;<code>wxml</code>&#x6A21;&#x677F;&#x6587;&#x4EF6;&#x4E2D;&#x4F7F;&#x7528;&#x7EC4;&#x4EF6;&#xFF1A;<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-title">mybox</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-title">mybox</span>&gt;</span>
</code></pre>
</li>
</ol>
<h2 id="&#x4E09;&#x3001;&#x7ED9;&#x81EA;&#x5B9A;&#x4E49;&#x7EC4;&#x4EF6;&#x6DFB;&#x52A0;&#x5C5E;&#x6027;&#xFF1A;">&#x4E09;&#x3001;&#x7ED9;&#x81EA;&#x5B9A;&#x4E49;&#x7EC4;&#x4EF6;&#x6DFB;&#x52A0;&#x5C5E;&#x6027;&#xFF1A;</h2>
<ol>
<li><p>&#x5728;&#x7EC4;&#x4EF6;&#x7684;<code>js</code>&#x6587;&#x4EF6;&#x4E2D;&#xFF0C;&#x5728;<code>properties</code>&#x4E2D;&#x6DFB;&#x52A0;&#x5C5E;&#x6027;&#xFF0C;&#x6DFB;&#x52A0;&#x5C5E;&#x6027;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x9700;&#x8981;&#x6307;&#x5B9A;&#x4E24;&#x4E2A;&#x503C;&#xFF0C;&#x4E00;&#x4E2A;&#x662F;<code>type</code>&#xFF0C;&#x4EE3;&#x8868;&#x7684;&#x662F;&#x8FD9;&#x4E2A;&#x5C5E;&#x6027;&#x7684;&#x7C7B;&#x578B;&#xFF0C;&#x4E00;&#x4E2A;&#x662F;<code>value</code>&#xFF0C;&#x4EE3;&#x8868;&#x7684;&#x662F;&#x8FD9;&#x4E2A;&#x5C5E;&#x6027;&#x7684;&#x9ED8;&#x8BA4;&#x503C;&#x3002;&#x793A;&#x4F8B;&#x4EE3;&#x7801;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-js">Component({
 properties: {
   showInner: {
     type: <span class="hljs-built_in">Boolean</span>,
     value: <span class="hljs-literal">false</span>
   }
 }
})
</code></pre>
</li>
<li><p>&#x7136;&#x540E;&#x5728;<code>wxml</code>&#x6A21;&#x677F;&#x4E2D;&#x5C31;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&#x4E86;&#x3002;&#x793A;&#x4F8B;&#x4EE3;&#x7801;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-title">view</span> <span class="hljs-attribute">class</span>=<span class="hljs-value">&quot;outter&quot;</span>&gt;</span>
 <span class="hljs-tag">&lt;<span class="hljs-title">view</span> <span class="hljs-attribute">wx:if</span>=<span class="hljs-value">&quot;&quot;</span> <span class="hljs-attribute">class</span>=<span class="hljs-value">&quot;inner&quot;</span>&gt;</span>&#x77E5;&#x4E86;&#x8BFE;&#x5802;<span class="hljs-tag">&lt;/<span class="hljs-title">view</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-title">view</span>&gt;</span>
</code></pre>
</li>
<li><p>&#x5728;&#x4F7F;&#x7528;&#x7EC4;&#x4EF6;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x5728;&#x7EC4;&#x4EF6;&#x4E0A;&#x7ED9;&#x8FD9;&#x4E2A;&#x5C5E;&#x6027;&#x8BBE;&#x7F6E;&#x503C;&#xFF1A;</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-title">mybox</span> <span class="hljs-attribute">showInner</span>=<span class="hljs-value">&quot;true&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-title">mybox</span>&gt;</span>
</code></pre>
</li>
<li><p>&#x8FD8;&#x6709;&#x53E6;&#x5916;&#x4E00;&#x79CD;&#x4F7F;&#x7528;<code>data</code>&#x7684;&#x5F62;&#x5F0F;&#xFF0C;<code>data</code>&#x4E2D;&#x7684;&#x6570;&#x636E;&#x53EF;&#x4EE5;&#x6E32;&#x67D3;&#x5230;&#x7EC4;&#x4EF6;&#x7684;&#x4EE3;&#x7801;&#x4E2D;&#xFF0C;&#x4F46;&#x662F;&#x4F7F;&#x7528;<code>data</code>&#x4E0D;&#x80FD;&#x4F5C;&#x4E3A;&#x5C5E;&#x6027;&#x6765;&#x4F7F;&#x7528;&#x3002;</p>
</li>
</ol>
<h2 id="&#x4E09;&#x3001;&#x5728;&#x7EC4;&#x4EF6;&#x4E2D;&#x6DFB;&#x52A0;&#x8282;&#x70B9;&#xFF1A;">&#x4E09;&#x3001;&#x5728;&#x7EC4;&#x4EF6;&#x4E2D;&#x6DFB;&#x52A0;&#x8282;&#x70B9;&#xFF1A;</h2>
<p>&#x5728;&#x4F7F;&#x7528;&#x5C0F;&#x7A0B;&#x5E8F;&#x5185;&#x7F6E;&#x7684;&#x7EC4;&#x4EF6;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x6BD4;&#x5982;<code>view</code>&#xFF0C;&#x6211;&#x4EEC;&#x8FD8;&#x53EF;&#x4EE5;&#x5728;<code>view</code>&#x4E2D;&#x6DFB;&#x52A0;&#x5176;&#x4ED6;&#x7684;&#x7EC4;&#x4EF6;&#x3002;&#x8FD9;&#x4E2A;&#x529F;&#x80FD;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;<code>slot</code>&#x8282;&#x70B9;&#x6765;&#x5B9E;&#x73B0;&#x3002;&#x793A;&#x4F8B;&#x4EE3;&#x7801;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-title">view</span> <span class="hljs-attribute">class</span>=<span class="hljs-value">&quot;outter&quot;</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-title">view</span> <span class="hljs-attribute">wx:if</span>=<span class="hljs-value">&quot;&quot;</span> <span class="hljs-attribute">class</span>=<span class="hljs-value">&quot;inner&quot;</span>&gt;</span>&#x77E5;&#x4E86;&#x8BFE;&#x5802;<span class="hljs-tag">&lt;/<span class="hljs-title">view</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-title">slot</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-title">slot</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-title">view</span>&gt;</span>
</code></pre>
<p>&#x4EE5;&#x540E;&#x5728;&#x4F7F;&#x7528;&#x8FD9;&#x4E2A;&#x7EC4;&#x4EF6;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x8FD8;&#x53EF;&#x4EE5;&#x6DFB;&#x52A0;&#x81EA;&#x5DF1;&#x7684;&#x8282;&#x70B9;&#x3002;&#x793A;&#x4F8B;&#x4EE3;&#x7801;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-title">mybox</span> <span class="hljs-attribute">showInner</span>=<span class="hljs-value">&quot;true&quot;</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-title">view</span>&gt;</span>&#x8FD9;&#x662F;index&#x4E2D;&#x6DFB;&#x52A0;&#x7684;<span class="hljs-tag">&lt;/<span class="hljs-title">view</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-title">mybox</span>&gt;</span>
</code></pre>
<p>&#x4EE5;&#x4E0A;&#x662F;&#x6DFB;&#x52A0;&#x4E00;&#x4E2A;<code>slot</code>&#xFF0C;&#x5982;&#x679C;&#x60F3;&#x8981;&#x6DFB;&#x52A0;&#x591A;&#x4E2A;<code>slot</code>&#xFF0C;&#x90A3;&#x4E48;&#x9700;&#x8981;&#x5728;<code>js</code>&#x6587;&#x4EF6;&#x4E2D;&#x6DFB;&#x52A0;&#x4E00;&#x4E2A;<code>multipleSlots</code>&#x5C5E;&#x6027;&#xFF0C;&#x793A;&#x4F8B;&#x4EE3;&#x7801;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-js">Component({
  options: {
    multipleSlots: <span class="hljs-literal">true</span>
  },
  ...
</code></pre>
<p>&#x7136;&#x540E;&#x5728;<code>wxml</code>&#x6587;&#x4EF6;&#x4E2D;&#xFF0C;&#x9700;&#x8981;&#x7ED9;&#x6BCF;&#x4E00;&#x4E2A;<code>slot</code>&#x90FD;&#x6307;&#x5B9A;<code>name</code>&#x3002;&#x793A;&#x4F8B;&#x4EE3;&#x7801;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-title">view</span> <span class="hljs-attribute">class</span>=<span class="hljs-value">&quot;outter&quot;</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-title">slot</span> <span class="hljs-attribute">name</span>=<span class="hljs-value">&quot;before&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-title">slot</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-title">view</span> <span class="hljs-attribute">wx:if</span>=<span class="hljs-value">&quot;&quot;</span> <span class="hljs-attribute">class</span>=<span class="hljs-value">&quot;inner&quot;</span>&gt;</span>&#x77E5;&#x4E86;&#x8BFE;&#x5802;<span class="hljs-tag">&lt;/<span class="hljs-title">view</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-title">slot</span> <span class="hljs-attribute">name</span>=<span class="hljs-value">&quot;after&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-title">slot</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-title">view</span>&gt;</span>
</code></pre>
<p>&#x6700;&#x540E;&#x5728;&#x4F7F;&#x7528;&#x8FD9;&#x4E2A;&#x7EC4;&#x4EF6;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x4E5F;&#x9700;&#x8981;&#x6307;&#x5B9A;&#x653E;&#x5728;&#x90A3;&#x4E2A;<code>slot</code>&#x4E2D;&#x3002;&#x793A;&#x4F8B;&#x4EE3;&#x7801;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-title">mybox</span> <span class="hljs-attribute">showInner</span>=<span class="hljs-value">&quot;true&quot;</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-title">view</span> <span class="hljs-attribute">slot</span>=<span class="hljs-value">&quot;before&quot;</span>&gt;</span>&#x8FD9;&#x662F;before&#x7684;&#x7EC4;&#x4EF6;<span class="hljs-tag">&lt;/<span class="hljs-title">view</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-title">view</span> <span class="hljs-attribute">slot</span>=<span class="hljs-value">&quot;after&quot;</span>&gt;</span>&#x8FD9;&#x662F;after&#x7684;&#x7EC4;&#x4EF6;<span class="hljs-tag">&lt;/<span class="hljs-title">view</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-title">mybox</span>&gt;</span>
</code></pre>
<h2 id="&#x7EC4;&#x4EF6;&#x6837;&#x5F0F;&#x6CE8;&#x610F;&#x4E8B;&#x9879;&#xFF1A;">&#x7EC4;&#x4EF6;&#x6837;&#x5F0F;&#x6CE8;&#x610F;&#x4E8B;&#x9879;&#xFF1A;</h2>
<p>&#x7EC4;&#x4EF6;&#x5BF9;&#x5E94; wxss &#x6587;&#x4EF6;&#x7684;&#x6837;&#x5F0F;&#xFF0C;&#x53EA;&#x5BF9;&#x7EC4;&#x4EF6;wxml&#x5185;&#x7684;&#x8282;&#x70B9;&#x751F;&#x6548;&#x3002;&#x7F16;&#x5199;&#x7EC4;&#x4EF6;&#x6837;&#x5F0F;&#x65F6;&#xFF0C;&#x9700;&#x8981;&#x6CE8;&#x610F;&#x4EE5;&#x4E0B;&#x51E0;&#x70B9;&#xFF1A;</p>
<ol>
<li>&#x7EC4;&#x4EF6;&#x548C;&#x5F15;&#x7528;&#x7EC4;&#x4EF6;&#x7684;&#x9875;&#x9762;&#x4E0D;&#x80FD;&#x4F7F;&#x7528;id&#x9009;&#x62E9;&#x5668;&#xFF08;#a&#xFF09;&#x3001;&#x5C5E;&#x6027;&#x9009;&#x62E9;&#x5668;&#xFF08;[a]&#xFF09;&#x548C;&#x6807;&#x7B7E;&#x540D;&#x9009;&#x62E9;&#x5668;&#xFF0C;&#x8BF7;&#x6539;&#x7528;class&#x9009;&#x62E9;&#x5668;&#x3002;</li>
<li>&#x7EC4;&#x4EF6;&#x548C;&#x5F15;&#x7528;&#x7EC4;&#x4EF6;&#x7684;&#x9875;&#x9762;&#x4E2D;&#x4F7F;&#x7528;&#x540E;&#x4EE3;&#x9009;&#x62E9;&#x5668;&#xFF08;.a .b&#xFF09;&#x5728;&#x4E00;&#x4E9B;&#x6781;&#x7AEF;&#x60C5;&#x51B5;&#x4E0B;&#x4F1A;&#x6709;&#x975E;&#x9884;&#x671F;&#x7684;&#x8868;&#x73B0;&#xFF0C;&#x5982;&#x9047;&#xFF0C;&#x8BF7;&#x907F;&#x514D;&#x4F7F;&#x7528;&#x3002;</li>
<li>&#x5B50;&#x5143;&#x7D20;&#x9009;&#x62E9;&#x5668;&#xFF08;.a&gt;.b&#xFF09;&#x53EA;&#x80FD;&#x7528;&#x4E8E; view &#x7EC4;&#x4EF6;&#x4E0E;&#x5176;&#x5B50;&#x8282;&#x70B9;&#x4E4B;&#x95F4;&#xFF0C;&#x7528;&#x4E8E;&#x5176;&#x4ED6;&#x7EC4;&#x4EF6;&#x53EF;&#x80FD;&#x5BFC;&#x81F4;&#x975E;&#x9884;&#x671F;&#x7684;&#x60C5;&#x51B5;&#x3002;</li>
<li>&#x7EE7;&#x627F;&#x6837;&#x5F0F;&#xFF0C;&#x5982; font &#x3001; color &#xFF0C;&#x4F1A;&#x4ECE;&#x7EC4;&#x4EF6;&#x5916;&#x7EE7;&#x627F;&#x5230;&#x7EC4;&#x4EF6;&#x5185;&#x3002;</li>
<li>&#x9664;&#x7EE7;&#x627F;&#x6837;&#x5F0F;&#x5916;&#xFF0C; app.wxss &#x4E2D;&#x7684;&#x6837;&#x5F0F;&#x3001;&#x7EC4;&#x4EF6;&#x6240;&#x5728;&#x9875;&#x9762;&#x7684;&#x7684;&#x6837;&#x5F0F;&#x5BF9;&#x81EA;&#x5B9A;&#x4E49;&#x7EC4;&#x4EF6;&#x65E0;&#x6548;&#x3002;</li>
</ol>
<pre><code class="lang-css"><span class="hljs-id">#a</span> <span class="hljs-rules">{ }</span> <span class="hljs-comment">/* &#x5728;&#x7EC4;&#x4EF6;&#x4E2D;&#x4E0D;&#x80FD;&#x4F7F;&#x7528; */</span>
<span class="hljs-attr_selector">[a]</span> <span class="hljs-rules">{ }</span> <span class="hljs-comment">/* &#x5728;&#x7EC4;&#x4EF6;&#x4E2D;&#x4E0D;&#x80FD;&#x4F7F;&#x7528; */</span>
<span class="hljs-tag">button</span> <span class="hljs-rules">{ }</span> <span class="hljs-comment">/* &#x5728;&#x7EC4;&#x4EF6;&#x4E2D;&#x4E0D;&#x80FD;&#x4F7F;&#x7528; */</span>
<span class="hljs-class">.a</span> &gt; <span class="hljs-class">.b</span> <span class="hljs-rules">{ }</span> <span class="hljs-comment">/* &#x9664;&#x975E; .a &#x662F; view &#x7EC4;&#x4EF6;&#x8282;&#x70B9;&#xFF0C;&#x5426;&#x5219;&#x4E0D;&#x4E00;&#x5B9A;&#x4F1A;&#x751F;&#x6548; */</span>
</code></pre>
<h2 id="&#x4E8B;&#x4EF6;&#xFF1A;">&#x4E8B;&#x4EF6;&#xFF1A;</h2>
<ol>
<li><p>&#x7EC4;&#x4EF6;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x518D;&#x5916;&#x9762;&#x7ED1;&#x5B9A;&#x4E8B;&#x4EF6;&#x3002;&#x793A;&#x4F8B;&#x4EE3;&#x7801;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-html">// my-component&#x7EC4;&#x4EF6;&#x4EE3;&#x7801;
<span class="hljs-tag">&lt;<span class="hljs-title">view</span>&gt;</span>
 &#x7EC4;&#x4EF6;&#x5185;&#x7684;&#x4EE3;&#x7801;
<span class="hljs-tag">&lt;/<span class="hljs-title">view</span>&gt;</span>
</code></pre>
<p>&#x7136;&#x540E;&#x5728;&#x4F7F;&#x7528;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x76F4;&#x63A5;&#x5728;&#x4E0A;&#x9762;&#x7ED1;&#x5B9A;&#x5C31;&#x53EF;&#x4EE5;&#x4E86;&#x3002;</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-title">my-component</span> <span class="hljs-attribute">bindtap</span>=<span class="hljs-value">&quot;tapEvent&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-title">my-component</span>&gt;</span>
</code></pre>
</li>
<li><p>&#x81EA;&#x5B9A;&#x4E49;&#x7EC4;&#x4EF6;&#x4E8B;&#x4EF6;&#x3002;&#x76F4;&#x63A5;&#x5728;&#x7EC4;&#x4EF6;&#x5185;&#x7ED1;&#x5B9A;&#x4E8B;&#x4EF6;&#x3002;&#x5E76;&#x4E14;&#x5982;&#x679C;&#x6211;&#x4EEC;&#x60F3;&#x5728;&#x7EC4;&#x4EF6;&#x5185;&#x6355;&#x83B7;&#x5230;&#x4E8B;&#x4EF6;&#x540E;&#xFF0C;&#x8981;&#x901A;&#x77E5;&#x5230;&#x7236;&#x7EC4;&#x4EF6;&#xFF0C;&#x90A3;&#x4E48;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;<code>triggerEvent</code>&#x65B9;&#x6CD5;&#x6765;&#x89E6;&#x53D1;&#x81EA;&#x5B9A;&#x4E49;&#x7684;&#x4E8B;&#x4EF6;&#x3002;&#x793A;&#x4F8B;&#x4EE3;&#x7801;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-html">// my-component&#x7EC4;&#x4EF6;&#x4EE3;&#x7801;
<span class="hljs-tag">&lt;<span class="hljs-title">view</span> <span class="hljs-attribute">class</span>=<span class="hljs-value">&quot;outter&quot;</span>&gt;</span>
 <span class="hljs-tag">&lt;<span class="hljs-title">view</span> <span class="hljs-attribute">class</span>=<span class="hljs-value">&quot;inner&quot;</span> <span class="hljs-attribute">bindtap</span>=<span class="hljs-value">&quot;onInnerTapEvent&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-title">view</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-title">view</span>&gt;</span>
</code></pre>
<p>&#x7136;&#x540E;&#x5728;&#x7EC4;&#x4EF6;&#x7684;<code>js</code>&#x6587;&#x4EF6;&#x4E2D;&#xFF0C;&#x4F7F;&#x7528;&#x4EE5;&#x4E0B;&#x4EE3;&#x7801;&#x8FDB;&#x884C;&#x6355;&#x83B7;&#x548C;&#x4F20;&#x9012;&#x7ED9;&#x7236;&#x7EC4;&#x4EF6;&#x3002;&#x793A;&#x4F8B;&#x4EE3;&#x7801;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-js">Component({
 method: {
   onInnerTapEvent: <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">event</span>)</span>{
     <span class="hljs-built_in">console</span>.log(<span class="hljs-string">&quot;&#x7EC4;&#x4EF6;&#x5185;&#x76D1;&#x542C;&#x5230;&#x4E86;innerTapEvent&#x4E8B;&#x4EF6;&quot;</span>);
     <span class="hljs-keyword">var</span> detail = {} <span class="hljs-comment">// detail&#x5BF9;&#x8C61;&#xFF0C;&#x63D0;&#x4F9B;&#x7ED9;&#x4E8B;&#x4EF6;&#x76D1;&#x542C;&#x51FD;&#x6570;</span>
     <span class="hljs-keyword">var</span> option = {} <span class="hljs-comment">// &#x89E6;&#x53D1;&#x4E8B;&#x4EF6;&#x7684;&#x9009;&#x9879;</span>
     <span class="hljs-keyword">this</span>.triggerEvent(<span class="hljs-string">&quot;customevent&quot;</span>,detail,option);
   }
 }
})
</code></pre>
<p>&#x7136;&#x540E;&#x5728;&#x4F7F;&#x7528;&#x7EC4;&#x4EF6;&#x7684;&#x5730;&#x65B9;&#xFF0C;&#x9700;&#x8981;&#x7ED9;&#x81EA;&#x5B9A;&#x4E49;&#x4E8B;&#x4EF6;&#x7ED1;&#x5B9A;&#x76D1;&#x542C;&#x65B9;&#x6CD5;&#x3002;&#x793A;&#x4F8B;&#x4EE3;&#x7801;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-title">my-component</span> <span class="hljs-attribute">bindcustomevent</span>=<span class="hljs-value">&quot;onCustomEventEvent&quot;</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-title">my-component</span>&gt;</span>
</code></pre>
<p>&#x5176;&#x4E2D;&#x7684;<code>detail</code>&#x662F;&#x5728;&#x89E6;&#x53D1;<code>innerEvent</code>&#x4E8B;&#x4EF6;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x4F20;&#x9012;&#x7ED9;&#x5916;&#x9762;&#x63A5;&#x6536;&#x8FD9;&#x4E2A;&#x4E8B;&#x4EF6;&#x7684;&#x5BF9;&#x8C61;&#x4E00;&#x4E9B;&#x989D;&#x5916;&#x7684;&#x4FE1;&#x606F;&#xFF0C;<code>option</code>&#x662F;&#x4E00;&#x4E9B;&#x9009;&#x9879;&#x3002;&#x8FD9;&#x4E9B;&#x9009;&#x9879;&#x53EF;&#x4EE5;&#x5982;&#x4E0B;&#xFF1A;</p>
<p>| &#x9009;&#x9879;&#x540D; | &#x7C7B;&#x578B; | &#x662F;&#x5426;&#x5FC5;&#x586B; | &#x9ED8;&#x8BA4;&#x503C; | &#x63CF;&#x8FF0; |
| --- | --- | --- | --- | --- |
| bubbles | Boolean | &#x5426; | false | &#x4E8B;&#x4EF6;&#x662F;&#x5426;&#x5192;&#x6CE1; |
| composed | Boolean | &#x5426; | false | &#x4E8B;&#x4EF6;&#x662F;&#x5426;&#x53EF;&#x4EE5;&#x7A7F;&#x8D8A;&#x7EC4;&#x4EF6;&#x8FB9;&#x754C;&#xFF0C;&#x4E3A;false&#x65F6;&#xFF0C;&#x4E8B;&#x4EF6;&#x5C06;&#x53EA;&#x80FD;&#x5728;&#x5F15;&#x7528;&#x7EC4;&#x4EF6;&#x7684;&#x8282;&#x70B9;&#x6811;&#x4E0A;&#x89E6;&#x53D1;&#xFF0C;&#x4E0D;&#x8FDB;&#x5165;&#x5176;&#x4ED6;&#x4EFB;&#x4F55;&#x7EC4;&#x4EF6;&#x5185;&#x90E8; |
| capturePhase | Boolean | &#x5426; | false | &#x4E8B;&#x4EF6;&#x662F;&#x5426;&#x62E5;&#x6709;&#x6355;&#x83B7;&#x9636;&#x6BB5; |</p>
</li>
</ol>
<h2 id="&#x751F;&#x547D;&#x5468;&#x671F;&#xFF1A;">&#x751F;&#x547D;&#x5468;&#x671F;&#xFF1A;</h2>
<h3 id="&#x7EC4;&#x4EF6;&#x672C;&#x8EAB;&#x7684;&#x751F;&#x547D;&#x5468;&#x671F;&#xFF1A;">&#x7EC4;&#x4EF6;&#x672C;&#x8EAB;&#x7684;&#x751F;&#x547D;&#x5468;&#x671F;&#xFF1A;</h3>
<p>&#x7EC4;&#x4EF6;&#x7684;&#x751F;&#x547D;&#x5468;&#x671F;&#xFF0C;&#x6307;&#x7684;&#x662F;&#x7EC4;&#x4EF6;&#x81EA;&#x8EAB;&#x7684;&#x4E00;&#x4E9B;&#x51FD;&#x6570;&#xFF0C;&#x8FD9;&#x4E9B;&#x51FD;&#x6570;&#x5728;&#x7279;&#x6B8A;&#x7684;&#x65F6;&#x95F4;&#x70B9;&#x6216;&#x9047;&#x5230;&#x4E00;&#x4E9B;&#x7279;&#x6B8A;&#x7684;&#x6846;&#x67B6;&#x4E8B;&#x4EF6;&#x65F6;&#x88AB;&#x81EA;&#x52A8;&#x89E6;&#x53D1;&#x3002;</p>
<p>&#x5176;&#x4E2D;&#xFF0C;&#x6700;&#x91CD;&#x8981;&#x7684;&#x751F;&#x547D;&#x5468;&#x671F;&#x662F;<code>created/attached/detached</code>&#xFF0C;&#x5305;&#x542B;&#x4E00;&#x4E2A;&#x7EC4;&#x4EF6;&#x5B9E;&#x4F8B;&#x751F;&#x547D;&#x6D41;&#x7A0B;&#x7684;&#x6700;&#x4E3B;&#x8981;&#x65F6;&#x95F4;&#x70B9;&#x3002;&#xFF08;&#x6CE8;&#x610F;&#xFF1A;&#x5728;2.2.3&#x57FA;&#x7840;&#x5E93;&#x4E4B;&#x524D;&#xFF0C;&#x751F;&#x547D;&#x5468;&#x671F;&#x51FD;&#x6570;&#x5199;&#x5728;<code>Component</code>&#x4E2D;&#x5C31;&#x53EF;&#x4EE5;&#xFF0C;&#x5728;<code>2.2.3</code>&#x540E;&#x5E94;&#x8BE5;&#x5199;&#x5728;<code>lifetimes</code>&#x4E2D;&#x3002;&#xFF09;</p>
<ol>
<li>&#x7EC4;&#x4EF6;&#x5B9E;&#x4F8B;&#x521A;&#x521A;&#x88AB;&#x521B;&#x5EFA;&#x597D;&#x65F6;&#xFF0C;<code>created</code>&#x751F;&#x547D;&#x5468;&#x671F;&#x88AB;&#x89E6;&#x53D1;&#x3002;&#x6B64;&#x65F6;&#xFF0C;&#x7EC4;&#x4EF6;&#x6570;&#x636E;<code>this.data</code>&#x5C31;&#x662F;&#x5728;<code>Component</code>&#x6784;&#x9020;&#x5668;&#x4E2D;&#x5B9A;&#x4E49;&#x7684;&#x6570;&#x636E;<code>data</code>&#x3002;&#x6B64;&#x65F6;&#x8FD8;&#x4E0D;&#x80FD;&#x8C03;&#x7528;<code>setData</code>&#x3002;&#x901A;&#x5E38;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x8FD9;&#x4E2A;&#x751F;&#x547D;&#x5468;&#x671F;&#x53EA;&#x5E94;&#x8BE5;&#x7528;&#x4E8E;&#x7ED9;&#x7EC4;&#x4EF6;<code>this</code>&#x6DFB;&#x52A0;&#x4E00;&#x4E9B;&#x81EA;&#x5B9A;&#x4E49;&#x5C5E;&#x6027;&#x5B57;&#x6BB5;&#x3002;</li>
<li>&#x5728;&#x7EC4;&#x4EF6;&#x5B8C;&#x5168;&#x521D;&#x59CB;&#x5316;&#x5B8C;&#x6BD5;&#x3001;&#x8FDB;&#x5165;&#x9875;&#x9762;&#x8282;&#x70B9;&#x6811;&#x540E;&#xFF0C;<code>attached</code>&#x751F;&#x547D;&#x5468;&#x671F;&#x88AB;&#x89E6;&#x53D1;&#x3002;&#x6B64;&#x65F6;&#xFF0C;<code>this.data</code>&#x5DF2;&#x88AB;&#x521D;&#x59CB;&#x5316;&#x4E3A;&#x7EC4;&#x4EF6;&#x7684;&#x5F53;&#x524D;&#x503C;&#x3002;&#x8FD9;&#x4E2A;&#x751F;&#x547D;&#x5468;&#x671F;&#x5F88;&#x6709;&#x7528;&#xFF0C;&#x7EDD;&#x5927;&#x591A;&#x6570;&#x521D;&#x59CB;&#x5316;&#x5DE5;&#x4F5C;&#x53EF;&#x4EE5;&#x5728;&#x8FD9;&#x4E2A;&#x65F6;&#x673A;&#x8FDB;&#x884C;&#x3002;</li>
<li>&#x5728;&#x7EC4;&#x4EF6;&#x79BB;&#x5F00;&#x9875;&#x9762;&#x8282;&#x70B9;&#x6811;&#x540E;&#xFF0C;<code>detached</code>&#x751F;&#x547D;&#x5468;&#x671F;&#x88AB;&#x89E6;&#x53D1;&#x3002;&#x9000;&#x51FA;&#x4E00;&#x4E2A;&#x9875;&#x9762;&#x65F6;&#xFF0C;&#x5982;&#x679C;&#x7EC4;&#x4EF6;&#x8FD8;&#x5728;&#x9875;&#x9762;&#x8282;&#x70B9;&#x6811;&#x4E2D;&#xFF0C;&#x5219; <code>detached</code>&#x4F1A;&#x88AB;&#x89E6;&#x53D1;&#x3002;</li>
</ol>
<h3 id="&#x76D1;&#x542C;&#x7EC4;&#x4EF6;&#x6240;&#x5728;&#x9875;&#x9762;&#x7684;&#x751F;&#x547D;&#x5468;&#x671F;&#xFF1A;">&#x76D1;&#x542C;&#x7EC4;&#x4EF6;&#x6240;&#x5728;&#x9875;&#x9762;&#x7684;&#x751F;&#x547D;&#x5468;&#x671F;&#xFF1A;</h3>
<p>&#x8FD8;&#x6709;&#x4E00;&#x4E9B;&#x7279;&#x6B8A;&#x7684;&#x751F;&#x547D;&#x5468;&#x671F;&#xFF0C;&#x5B83;&#x4EEC;&#x5E76;&#x975E;&#x4E0E;&#x7EC4;&#x4EF6;&#x6709;&#x5F88;&#x5F3A;&#x7684;&#x5173;&#x8054;&#xFF0C;&#x4F46;&#x6709;&#x65F6;&#x7EC4;&#x4EF6;&#x9700;&#x8981;&#x83B7;&#x77E5;&#xFF0C;&#x4EE5;&#x4FBF;&#x7EC4;&#x4EF6;&#x5185;&#x90E8;&#x5904;&#x7406;&#x3002;&#x8FD9;&#x6837;&#x7684;&#x751F;&#x547D;&#x5468;&#x671F;&#x79F0;&#x4E3A;&#x201C;&#x7EC4;&#x4EF6;&#x6240;&#x5728;&#x9875;&#x9762;&#x7684;&#x751F;&#x547D;&#x5468;&#x671F;&#x201D;&#xFF0C;&#x5728; pageLifetimes &#x5B9A;&#x4E49;&#x6BB5;&#x4E2D;&#x5B9A;&#x4E49;&#x3002;&#x5176;&#x4E2D;&#x53EF;&#x7528;&#x7684;&#x751F;&#x547D;&#x5468;&#x671F;&#x5305;&#x62EC;&#xFF1A;</p>
<table>
<thead>
<tr>
<th>&#x751F;&#x547D;&#x5468;&#x671F;</th>
<th>&#x53C2;&#x6570;</th>
<th>&#x63CF;&#x8FF0;</th>
<th>&#x6700;&#x4F4E;&#x7248;&#x672C;</th>
</tr>
</thead>
<tbody>
<tr>
<td>show</td>
<td>&#x65E0;</td>
<td>&#x7EC4;&#x4EF6;&#x6240;&#x5728;&#x7684;&#x9875;&#x9762;&#x88AB;&#x5C55;&#x793A;&#x65F6;&#x6267;&#x884C;</td>
<td>2.2.3</td>
</tr>
<tr>
<td>hide</td>
<td>&#x65E0;</td>
<td>&#x7EC4;&#x4EF6;&#x6240;&#x5728;&#x7684;&#x9875;&#x9762;&#x88AB;&#x9690;&#x85CF;&#x65F6;&#x6267;&#x884C;</td>
<td>2.2.3</td>
</tr>
<tr>
<td>resize</td>
<td>Object Size</td>
<td>&#x7EC4;&#x4EF6;&#x6240;&#x5728;&#x7684;&#x9875;&#x9762;&#x5C3A;&#x5BF8;&#x53D8;&#x5316;&#x65F6;&#x6267;&#x884C;</td>
<td>2.4.0</td>
</tr>
</tbody>
</table>

                    
                    </section>
                
                
                </div>
            </div>
        </div>

        
        <a href="../di-san-zhang-ff1a-chang-yong-zu-jian/di-liu-jie-ff1a-input-zu-jian.html" class="navigation navigation-prev " aria-label="Previous page: 第六节：input组件"><i class="fa fa-angle-left"></i></a>
        
        
        <a href="../di-yi-jie-ff1a-wang-luo-qing-qiu-api.html" class="navigation navigation-next " aria-label="Next page: 第一节：网络请求API"><i class="fa fa-angle-right"></i></a>
        
    </div>
</div>

        
<script src="../gitbook/app.js"></script>

    
    <script src="../gitbook/plugins/gitbook-plugin-search/lunr.min.js"></script>
    

    
    <script src="../gitbook/plugins/gitbook-plugin-search/search.js"></script>
    

    
    <script src="../gitbook/plugins/gitbook-plugin-sharing/buttons.js"></script>
    

    
    <script src="../gitbook/plugins/gitbook-plugin-fontsettings/buttons.js"></script>
    

<script>
require(["gitbook"], function(gitbook) {
    var config = {"highlight":{},"search":{"maxIndexSize":1000000},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2}};
    gitbook.start(config);
});
</script>

        
    </body>
    
</html>
